package stz.flash.option.flashlight;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import stz.flash.option.OptionLabel;
import stz.flash.string.OptionInformation;
import stz.flash.string.OptionString;
import blackberry.util.field.DjCheckboxField;
import blackberry.util.field.DjLabelField;


public class LEDStartupStateCheckbox extends DjCheckboxField implements FieldChangeListener{
	
	public LEDStartupStateCheckbox() {
		super(DjLabelField.createSimpleLabel(OptionString.LED_STARTUP_STATE_CHECKBOX_LABEL),
				OptionLabel.createInfoLabel(OptionInformation.LED_STARTUP_STATE_CHECKBOX_INFORMATION),
				LEDOption.getIns().isStartupLedState());
		setChangeListener(this);
	}
	
	public void fieldChanged(Field arg0, int context) {
		if (PROGRAMMATIC == context) {
			return;
		}
		if (getChecked()) { 
			setStartupLedState(true);}
		else {
			setStartupLedState(false);
		}
	}
	
	private void setStartupLedState(boolean ledState){
		LEDOption.getIns().setStartupLedState(ledState);
	}
}
